<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    xmlns:xhtml="http://www.w3.org/1999/xhtml"
    xmlns:oxf="http://www.orbeon.com/oxf/processors"
    xmlns:xforms="http://www.w3.org/2002/xforms"
    xmlns:xxforms="http://orbeon.org/oxf/xml/xforms">
    
    <p:param type="input" name="xformed-data"/>
    
    <!-- Get request information -->
    <p:processor name="oxf:request">
        <p:input name="config">
            <config>
                <include>/request/container-type</include>
                <include>/request/request-path</include>
                <include>/request/context-path</include>
            </config>
        </p:input>
        <p:output name="data" id="request"/>
    </p:processor>
    
    <!-- Read css & img directory -->
    <p:processor name="oxf:directory-scanner">
        <p:input name="config">
            <config>
                <base-directory>oxf:.</base-directory>
                <include>css/*.css</include>
                <include>js/*.js</include>
            </config>
        </p:input>
        <p:output name="data" id="directories"></p:output>
    </p:processor>
    
    <!-- The container is a portlet -->
    <p:choose href="#xformed-data">
        <!-- XHTML detection. Don't transform the content. -->
        <p:when test="/xhtml:html">
            <p:processor name="oxf:identity">
                <p:input name="data" href="#xformed-data"/>
                <p:output name="data" id="xformed-data-2"/>
            </p:processor>
        </p:when>
        <!-- No particular document format detected. Create an XHTML document which formats the XML content. -->
        <p:otherwise>
            <p:processor name="oxf:unsafe-xslt">
                <p:input name="data" href="#xformed-data"/>
                <p:input name="request" href="#request"/>
                <p:input name="config">
                    <xsl:stylesheet version="2.0"
                        xmlns:f="http://orbeon.org/oxf/xml/formatting" xmlns:xhtml="http://www.w3.org/1999/xhtml">
                        <xsl:template match="/">
                            <xhtml:html>
                                <xhtml:head><xhtml:title>XML Document</xhtml:title></xhtml:head>
                                <xhtml:body>
                                    <f:xml-source>
                                        <xsl:copy-of select="/*"/>
                                    </f:xml-source>
                                </xhtml:body>
                            </xhtml:html>
                        </xsl:template>
                    </xsl:stylesheet>
                </p:input>
                <p:output name="data" id="xformed-data-2"/>
            </p:processor>
        </p:otherwise>
    </p:choose>
    <!-- Apply theme, headers & footers -->
    <p:processor name="oxf:unsafe-xslt">
        <p:input name="data" href="#xformed-data-2"/>
        <p:input name="request" href="#request"/>
        <p:input name="directories" href="#directories"/>
        <p:input name="config">
            <xsl:stylesheet version="2.0"
                xmlns:f="http://orbeon.org/oxf/xml/formatting" xmlns:xhtml="http://www.w3.org/1999/xhtml"
                xmlns:context="java:org.orbeon.oxf.pipeline.StaticExternalContext">
                <xsl:template match="/">
                    <xhtml:html>
                    <xhtml:head>
                    <!-- Styles and scripts -->
                    <xhtml:link rel="stylesheet" type="text/css" href="/apps/css/common.css" />
                    <xhtml:link rel="stylesheet" type="text/css" href="/apps/css/forms.css" />
                    <xhtml:link rel="stylesheet" type="text/css" href="/apps/css/login.css" />
                    <xhtml:link rel="stylesheet" type="text/css" href="/apps/css/register.css" />
                    <xhtml:link rel="stylesheet" type="text/css" href="/apps/login/fix-ie7.css" />
                    <xsl:copy-of select="/xhtml:html/xhtml:head/(xhtml:style | xhtml:link | xhtml:script | xhtml:title)"/>
                    </xhtml:head>
        
                    <xhtml:body>
                        <xsl:copy-of select="/xhtml:html/xhtml:body/node()"/>
                        <xhtml:div id="footer">
                            <xhtml:a href="http://palette.ercim.org">
                                <xhtml:img class="footer_logo" src="/apps/img/logo.png" alt="PALETTE is an Integrated Project supported by the IST programme of the European Commission" title="PALETTE is an Integrated Project supported by the IST programme of the European Commission"/>
                            </xhtml:a>
                            <xhtml:a href="http://europa.eu">
                                <xhtml:img class="footer_logo" src="/apps/img/footer-eu.png" alt="PALETTE is an Integrated Project supported by the IST programme of the European Commission" title="PALETTE is an Integrated Project supported by the IST programme of the European Commission"/>
                            </xhtml:a>
                            <xhtml:a href="http://www.tudor.lu">
                                <xhtml:img class="footer_logo" src="/apps/img/footer-tudor.png" alt="Public Research Center Henri Tudor" title="Centre de Recherche Public Henri Tudor"/>
                            </xhtml:a>
                            <xhtml:p>
                                Copyright 2007-2008 Public Research Center Henri Tudor.
                            </xhtml:p>
                        </xhtml:div>
                    </xhtml:body>
                    </xhtml:html>
                </xsl:template>
            </xsl:stylesheet>
        </p:input>
        <p:output name="data" id="themed-data"/>
    </p:processor>
    <!-- Rewrite all URLs in XHTML documents -->
    <p:processor name="oxf:xhtml-rewrite" >
        <p:input name="rewrite-in" href="#themed-data"/>
        <p:output name="rewrite-out" id="rewritten-data" />
    </p:processor>
    <!-- Move from XHTML namespace to no namespace -->
    <p:processor name="oxf:qname-converter">
        <p:input name="config">
            <config>
                <match>
                    <uri>http://www.w3.org/1999/xhtml</uri>
                </match>
                <replace>
                    <uri></uri>
                    <prefix></prefix>
                </replace>
            </config>
        </p:input>
        <p:input name="data" href="#rewritten-data"/>
        <p:output name="data" id="html-data"/>
    </p:processor>
    <!-- Convert and serialize to HTML -->
    <p:processor name="oxf:html-converter">
        <p:input name="config">
            <config>
                <!-- Not necessary to indent at this point -->
                <indent>false</indent>
                <!-- Do not output any doctype, this is a fragment -->
            </config>
        </p:input>
        <p:input name="data" href="#html-data"/>
        <p:output name="data" id="converted"/>
    </p:processor>
    <p:processor name="oxf:http-serializer">
        <p:input name="config">
            <config>
                <!-- Disable caching, so that the title is always generated -->
                <cache-control>
                    <use-local-cache>false</use-local-cache>
                </cache-control>
            </config>
        </p:input>
        <p:input name="data" href="#converted"/>
    </p:processor>
    
</p:config>
